package annotation.config;


import annotation.bean.Cat;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

/**
 * 这是一个配置类
 *
 * @author: MI
 * @email: 448341911@qq.com
 * @createTime: 2024/6/10 11:20
 * @updateUser: MI
 * @updateTime: 2024/6/10 11:20
 * @updateRemark: 修改内容
 * @version: v1.0
 */
//@Import({Person.class, BeanConfig.MyImportRegistrar.class})
@ComponentScan("annotation")
@Configuration
public class BeanConfig {


    /**
     * BeanDefinitionRegistry： Bean定义信息注册中心，图纸中心
     */
    static class MyImportRegistrar implements ImportBeanDefinitionRegistrar {

        @Override
        public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {

            // BeanDefinition
            RootBeanDefinition catDefinition = new RootBeanDefinition();
            catDefinition.setBeanClass(Cat.class);
            // Spring这个实例的类型，名字
            registry.registerBeanDefinition("tomCat", catDefinition);
        }
    }

}
